package threadScheduling;

import java.util.jar.JarOutputStream;

public class giveway extends Thread{

    public giveway(String name){
        super(name);
    }

    public void run(){
        for(int i=0;i<10;i++){
            System.out.println(Thread.currentThread().getName()+"------"+i);
            if (i == 2) {
                System.out.println("线程让步~~");
                Thread.yield();
            }
        }
    }

    public static void main(String[] args) {

        // 创建3个线程
        Thread thread1 = new giveway("线程1");
        Thread thread2 = new giveway("线程2");
        Thread thread3 = new giveway("线程3");

        thread1.setPriority(2);
        thread2.setPriority(6);
        thread3.setPriority(8);

        thread2.start();
        thread1.start();
        thread3.start();
    }
}
